﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading;
using System.Data.SqlClient;
namespace ParentTest
{
    public partial class Form1 : Form
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);

        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

        [DllImport("user32.dll")]
        static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        const int WM_SYSCOMMAND = 274;
        const int SC_MAXIMIZE = 61488;

        string m_agrTempConnectionString = @"Data Source=172.16.10.213\AGRESSO;database=AGRWIN_INTERFACE_DB;User ID=WinSDS;password=80Grams;";
        SqlConnection m_softmarSQLConnection;

        public Form1()
        {
            InitializeComponent();
            this.Text = this.Handle.ToString();
            //Process proc = Process.Start(
            //        new ProcessStartInfo()
            //        {
            //            FileName = "cmd",
            //            Arguments = "/c echo hello user ^<!^> && pause",
            //            WindowStyle = ProcessWindowStyle.Minimized
            //        });
            //Thread.Sleep(1000);
            ////ShowWindow(proc.MainWindowHandle, 0);
            //SetParent(proc.MainWindowHandle, this.Handle);
            ////ShowWindow(proc.MainWindowHandle, 1);
            //SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
            ////SetParent(FindWindow(vbnullstring,"notepad.exe"),me.handle)
            //this.SuspendLayout();

            //Process runProcess = new Process();
            //ProcessStartInfo info = new ProcessStartInfo();
            //info.FileName = "NotePad.exe";
            //info.WindowStyle = ProcessWindowStyle.Normal;
            //runProcess = Process.Start(info);
            //Thread.Sleep(1000);
            //SetParent(runProcess.MainWindowHandle, this.Handle);
            //this.ResumeLayout();

            //m_softmarSQLConnection= new SqlConnection(m_agrTempConnectionString);
            //m_softmarSQLConnection.Open();
            //SqlDataAdapter da = new SqlDataAdapter("select * from i_bunker_grn_temp where grade = 'IFO'", m_softmarSQLConnection);
            //DataSet ds = new DataSet();
            //da.Fill(ds);
            //ds.WriteXmlSchema("i_bunker_grn_temp.xsd");
            //ds.WriteXml("i_bunker_grn_temp.xml", XmlWriteMode.IgnoreSchema);
            //m_softmarSQLConnection.Close();

        }
    }
}
